﻿/// <reference path="easyui/jquery-1.8.0.min.js" />
/// <reference path="easyui/jquery.easyui.min.js" />
var datetools = {};
datetools.day = function (da) {
    var y = da.getFullYear() + "-";
    var m = da.getMonth() + 1;
    var d = da.getDate();
    y = y + (m < 10 ? ("0" + m) : m) + "-" + (d < 10 ? ("0" + d) : d);
    return y;
};
$(function () {
    tick();
    setInterval("tick()", 1000);

});
function tick() {
    var today;
    today = new Date();
    $("#nowDate").html(format(today));
    //setTimeout("tick()", 1000);
}
function format(date) {
    //年
    var yy = date.getYear() + 1900;
    //月
    var MM = date.getMonth() + 1;
    //日
    var dd = date.getDate();
    //时
    var hh = date.getHours()
    //分
    var mm = date.getMinutes();
    //秒
    var ss = date.getSeconds();
    //星期
    var ww = date.getDay();
    var ssStr = "";
    switch (ww) {
        case 0:

            ssStr = "星期日"
            break;
        case 1:
            ssStr = "星期一"
            break;
        case 2:
            ssStr = "星期二"
            break;
        case 3:
            ssStr = "星期三"
            break;
        case 4:
            ssStr = "星期四"
            break;
        case 5:
            ssStr = "星期五"
            break;
        case 6:
            ssStr = "星期六"
            break
    }
    return yy + "年" + MM + "月" + dd + "日  " + hh + "时" + mm + "分" + ss + "秒     " + ssStr;
}

//记算与现在的时间间隔
function getDateDiff(datetime) {
    var nowDate = new Date();
    var date_time = new Date(datetime.replace(/-/g, "/"));
    var date = date_time.getTime() - nowDate.getTime();
    var time = Math.floor(date / (1000 * 60 * 60 * 24));
    return time;
};
//记算两时间的时间间隔
function getBetweenDateDiff(datetime1,datetime2) {
    
    var date_time1 = new Date(datetime1.replace(/-/g, "/"));
    var date_time2 = new Date(datetime2.replace(/-/g, "/"));
    var date = date_time1.getTime() - date_time2.getTime();
    var time = Math.floor(date / (1000 * 60 * 60 * 24));
    return time;
};

